package DaEr_5_25;



import java.util.*;

public class ArraytoList {


    public static void main(String[] args) {
//        ArraytoList arraytoList = new ArraytoList();
//        arraytoList.randlist();
        map = new HashMap<>();
        map.put("1","java");
        map.put("2","html");
        map.put("3","pathon");
        map.put("4","c++");
//        KeySetMethon();
        Set<Map.Entry<String, String>> entries = map.entrySet();
        Iterator<Map.Entry<String, String>> iterator = entries.iterator();
        while (iterator.hasNext()){
            Map.Entry<String, String> next = iterator.next();
            System.out.println("next.getValue() = " + next.getValue());
            System.out.println("next.getKey() = " + next.getKey());
            System.out.println("------------");
        }
    }
    public static Map<String,String> map;//定义属性
    public static void KeySetMethon(HashMap<String,String> map){
        Set<String> strings = map.keySet();
        Iterator<String> iterator = strings.iterator();
        while (iterator.hasNext()){
            System.out.println("iterator.next() = " + map.get(iterator.next()));
        }

    }
    public void Arraytolist1(){
        int total=10;
        String [] strings = new String[total];
        for (int i = 0; i < strings.length; i++) {
            strings[i]=String.valueOf(i);
        }
        List<String> list = Arrays.asList(strings);
        for (String s:list){
            System.out.println("s = " + s);
        }
    }
    public void AslistExaple(){
        String[] str={"java","pathon","c++","c"};
        List<String> list = Arrays.asList(str);
        ListIterator<String> stringListIterator = list.listIterator();
        System.out.println("反转前");
        Collections.sort(list);
        while (stringListIterator.hasNext()){
            System.out.println("stringListIterator.next() = " + stringListIterator.next());
        }
        Collections.reverse(list);
        System.out.println("反转后");
        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){
            System.out.println("iterator.next() = " + iterator.next());
        }

    }
    public void randlist(){
        ArrayList<Integer> integers = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            integers.add(i);
        }
        System.out.println("打乱前");
        System.out.println("integers = " + integers);

        for (int i = 0; i < 5; i++) {
            System.out.println("第"+i+"次打乱");
            Collections.shuffle(integers);
            System.out.println("integers = " + integers);
        }
    }
}
